﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Dal;

namespace Web
{
    public partial class forgotpassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btEmail_Click(object sender, EventArgs e)
        {
            ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
            if (!String.IsNullOrEmpty(txEmail.Text.Trim()))
            {
                if (scriptManager != null && scriptManager.IsInAsyncPostBack)
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(),
                                                        "alert('กรุณากรอก Email');", true);
                else
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), Guid.NewGuid().ToString(),
                                                            "alert('กรุณากรอก Email');", true);
            }
            else
            {
                DataTable dt = LoginDal.Init().GetPassword(txEmail.Text.Trim());
                if (dt != null) {
                    // Sender Email
                }
                else
                {
                    if (scriptManager != null && scriptManager.IsInAsyncPostBack)
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Email นี้ไม่มีอยู่ในระบบ');", true);
                    else
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), Guid.NewGuid().ToString(), "alert('Email นี้ไม่มีอยู่ในระบบ');", true);
                }

            }
        }
    }
}